﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>donw2-多文件演示页面</title>
    <script type="text/javascript" src="js/jquery-1.4.min.js"></script>
    <script type="text/javascript" src="js/down.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/demo.js" charset="utf-8"></script>
    <style type="text/css">
        h5 {margin:0;font-family: 微软雅黑 宋体;}
        p {font: 9pt 宋体;}
        ul {list-style-type: none;font: 9pt 宋体;}
        ul li {display: inline;margin: 0 5px 0 0;font: 9pt 宋体;}
    </style>
</head>
<body>
    <h5>多文件下载。</h5>
    <div id="demos"></div>
    <input type="button" value="自定义下载数据+目录" id="btn-down-svr-fd" />
    <div id="downDiv"></div>
    <script type="text/javascript" language="javascript">
        //根路径：http://localhost/api/up6/
        var pos = window.location.href.lastIndexOf("cus-files.htm");
        var api = window.location.href.substr(0, pos) + "db/";
        var downer = new DownloaderMgr({
            config: {
                License2: "",//请在此处配置授权码
                Folder: "",
                DataBase: false,//启用数据库支持
                //api
                "UrlCreate": api + "d_create.aspx",
                "UrlDel": api + "d_del.aspx",
                "UrlList": api + "d_list.aspx",
                "UrlUpdate": api + "d_update.aspx",
                "UrlDown": api + "down.aspx"
            },
            event: {
                taskCreate: function (f) {
                    $(document.body).append("文件ID：" + f.fileSvr.id) + "<br/>";
                    setTimeout(function () {
                        if (f.fields.auto == "1") downer.start_queue();
                    }, 300);
                },
                downProcess: function (obj) { },
                downStoped: function (obj) { },
                downComplete: function (obj) {
                    $(document.body).append('<div>本地路径：' + obj.fileSvr.pathLoc + '</div>');
                },
                downError: function (obj, err) { },
                queueComplete: function () {
                    $(document.body).append("<div>队列完成</div>");
                },
                //ready: function () { },
                selFolder: function (dir) {
                    setTimeout(function () {
                        if (downer.data.cur != null) {
                            downer.addJson(downer.data.cur);
                            downer.data.cur = null;
                        }
                    }, 100);
                }
            },
            ui: { render: "downDiv" }
        });

        $(function () {

            //自定义下载数据，db/down.aspx负责提供数据
            $("#btn-down-svr-fd").click(function () {
                var fd = {
                    nameLoc: "测试文件夹",
                    files: [
                        { fileUrl: api + "down.aspx", nameLoc: "360.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-1.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-2.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-3.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-4.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-5.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-6.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-7.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-8.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-9.exe" },
                        { fileUrl: api + "down.aspx", nameLoc: "360-10.exe" }
                    ]
                };
                if (downer.Config["Folder"] == "") {
                    downer.data.cur = fd;
                    downer.openFolder();
                    return;
                }

                downer.addJson(fd);
            });
        });
    </script>
</body>
</html>